export default class AppError extends Error {
  public code: ErrorCode;

  constructor({ message, cause, code }: { message: string; code: ErrorCode; cause?: any }) {
    super(message);
    this.cause = cause;
    this.code = code;
  }

  public static unauthError = () => new AppError({ code: "ERR_UNAUTHENTICATED", message: "未登录" });

  public static unhandledError = (message: string = "未知错误") => new AppError({ code: "ERR_UNHANDLED", message });
}
